//
//  EFSTradeDefine.h
//  EFSMobile
//
//  Created by Chuan on 12/10/15.
//  Copyright © 2015 Elephants Financial Service. All rights reserved.
//

#ifndef EFSMobile_EFSNFXGTradeDefine_h
#define EFSMobile_EFSNFXGTradeDefine_h

typedef NS_ENUM(NSUInteger, EFSNFXGTradeSocketCommand) {
    //开户、激活、登录
    //EFSNFXGTradeSocketCommandOpenAccount = 20000, /**< 新开户(登录占用了20000，这个端口待定) */
    EFSNFXGTradeSocketCommandModifyCardInformation = 20001, /**< 修改银行卡信息 */
    EFSNFXGTradeSocketCommandQueryBankList = 20002, /**< 获取结算银行列表 */
    EFSNFXGTradeSocketCommandContactNotification = 30003, /**< 签约反馈 */
    EFSNFXGTradeSocketCommandLogin = 20000, /**< 登录 */
    EFSNFXGTradeSocketCommandQueryTradeInfo = 20010, /**< 获取用户开户信息 */
    EFSNFXGTradeSocketCommandModifyPassword = 11032, /**< 密码修改 */
    EFSNFXGTradeSocketCommandLoginAgain = 9999, /**< 重新登录 */
    EFSNFXGTradeSocketCommandHeartBeat = 1004, /**< 心跳 */
    EFSNFXGTradeSocketCommandSaveTradePassWord = 50002, /**< 保存登录密码 */
    EFSNFXGTradeSocketCommandCheckTradePassWord = 50001, /**< 校验登录密码 */
    
    //忘记交易密码
    EFSNFXGTradeSocketCommandSendRefindPwdCode = 11052,//发送验证码
    EFSNFXGTradeSocketCommandResetPwd = 11053,
    
    // 交易、数据查询
    EFSNFXGTradeSocketCommandQueryTransactionOrderHistory = 50003, /**< 历史成交查询 */
    EFSNFXGTradeSocketCommandQueryOrderHistory = 50004, /**< 历史委托查询 */
    EFSNFXGTradeSocketCommandOpenStopOrder = 11016, /**< 止盈止损下单 */
    EFSNFXGTradeSocketCommandCloseStopOrder = 11017, /**< 止盈止损撤单 */
    EFSNFXGTradeSocketCommandOpenConditionalOrder = 11018, /**< 条件单下单 */
    EFSNFXGTradeSocketCommandCloseConditionalOrder = 11019, /**< 条件单撤单 */
    EFSNFXGTradeSocketCommandQueryStopOrder =  11020, /**< 止盈止损单查询 */
    EFSNFXGTradeSocketCommandQueryConditionalOrder = 11021, /**< 条件单查询 */
    EFSNFXGTradeSocketCommandQuerySignedTradeProtocol = 11029, /**< 签订代履行交收协议*/
    //EFSNFXGTradeSocketCommandQueryTransactionFee = 11002,
    /**< 交易手续费查询 */
    EFSNFXGTradeSocketCommandQueryUncompletedTransactionOrder = 11002, /**< 未成交查询 */
    EFSNFXGTradeSocketCommandQueryTransactionOrder = 11003, /**< 当日成交查询 */
    EFSNFXGTradeSocketCommandQueryClosedTransactionOrder = 11006, /**< 撤单查询 */
    EFSNFXGTradeSocketCommandQueryHoldingPosition = 11007, /**< 持仓查询 */
    EFSNFXGTradeSocketCommandQueryDeposit = 11008, /**< 保证金查询 */
    EFSNFXGTradeSocketCommandQueryOrder = 11011, /**< 今日委托查询 */
    EFSNFXGTradeSocketCommandOpenOrderWithLimitPrice = 11013, /**< 限价委托下单 */
    EFSNFXGTradeSocketCommandOpenOrderWithMarketPrice = 11014, /**< 市价委托下单 */
    EFSNFXGTradeSocketCommandCloseOrder = 11015, /**< 委托撤单 */
    EFSNFXGTradeSocketCommandOrderNotification = 30001, /**< 委托反馈，推送通知 */
    EFSNFXGTradeSocketCommandTransactionOrderNotification = 30002, /**< 成交反馈，推送通知 */
    EFSNFXGTradeSocketCommandMarketStatusNotification = 40001, /**< 市场状态变化通知 */
    EFSNFXGTradeSocketCommandQueryMarketStatus = 41001, /**< 市场状态查询 */
    EFSNFXGTradeSocketCommandQueryMarketConfig = 41004, /**< 市场参数 */
    
    // 资金
    EFSNFXGTradeSocketCommandClientLoginDepositManagement = 13001, /**< 客户端登录资金管理 */
    EFSNFXGTradeSocketCommandQueryBankDepositTransferDetail = 13002, /**< 交易商银行转账明细（此数据是由银行提供）*/
    EFSNFXGTradeSocketCommandModifyDepositPassword = 13003, /**< 修改资金密码 */
    EFSNFXGTradeSocketCommandTransferDepositToMarket = 13004, /**< 银行转市场（入金）*/
    EFSNFXGTradeSocketCommandTransferDepositToBank = 13005, /**< 市场转银行（出金）*/
    EFSNFXGTradeSocketCommandQueryBankAccountDeposit = 13006, /**< 查询银行卡余额 */
    EFSNFXGTradeSocketCommandQueryMarketDeposit = 13007, /**< 查询市场资金 */
    EFSNFXGTradeSocketCommandQueryDepositWhetherNeedPassword = 13008, /**< 查询是否需要密码 */
    EFSNFXGTradeSocketCommandCustomerWithdraws = 13011, /**< 客户提现*/
    EFSNFXGTradeSocketCommandQueryCustomerCanWithdrawCashBalances = 13012, /**< 查询可提现余额 */
    EFSNFXGTradeSocketCommandQueryCustomerWithdrawsDetail = 13013, /**< 提现明细*/
    EFSNFXGTradeSocketCommandQueryInformation = 11010 /**< 查询是否需要密码 */
};

typedef NS_ENUM(NSUInteger, EFSNFXGTradeSocketStatusCode) {
    EFSNFXGTradeSocketStatusCodeSuccess = 0, /**< 成功 */
    EFSNFXGTradeSocketStatusCodeFailure = 1, /**< 失败 业务操作失败时返回（提示信息根据业务而定） */
    EFSNFXGTradeSocketStatusCodeADAPTEREmpty = 2, /**< ADAPTER不能为空 */
    EFSNFXGTradeSocketStatusCodeAccountOrPasswordEmpty = 3, /**< 交易商编号、密码不能为空 */
    EFSNFXGTradeSocketStatusCodeROWSOrPageError = 4, /**< ROWS、PAGE不能为空、且只能为整数！ */
    EFSNFXGTradeSocketStatusCodeTokenEmpty = 5, /**< Token不能为空 */
    EFSNFXGTradeSocketStatusCodeUnLogin = 6, /**< 未登录 */
    EFSNFXGTradeSocketStatusCodeLoginAccountError = 11,
    EFSNFXGTradeSocketStatusCodeLoginPasswordError = 13,
    EFSNFXGTradeSocketStatusCodeSeviceError = 101 /**< 系统异常 */
};

static NSString * const kLoginServiceConnectedFailed = @"服务器连接失败";
static NSString * const kLoginAccountInvalid = @"账号未注册";
static NSString * const kLoginAccountGetError = @"账号信息获取失败";
static NSString * const kLoginPasswordError = @"密码错误";
static NSString * const kLoginGestureResetError = @"验证失效,请使用账号重新登录";

typedef NS_ENUM(NSUInteger, EFSNFXGTradeBuySellType)
{
    EFSNFXGTradeBuySellTypeBuy = 1, /**< 买入 */
    EFSNFXGTradeBuySellTypeSell = 2 /**< 卖出 */
};

typedef NS_ENUM(NSInteger, EFSNFXGTradeSocketConnectionStatus) {
    EFSNFXGTradeSocketStatusConnecting = 201,
    EFSNFXGTradeSocketStatusConnected,
    EFSNFXGTradeSocketStatusDisconnecting,
    EFSNFXGTradeSocketStatusDisconnected
};

typedef NS_ENUM(NSInteger, EFSNFXGTradeMarketStatus) {
    EFSNFXGTradeMarketStatusPrepareToOpen = 0, /**< 准备开盘 */
    EFSNFXGTradeMarketStatusOpen = 1, /**< 开盘 */
    EFSNFXGTradeMarketStatusClose = 2 /**< 收盘 */
};

typedef NS_ENUM(NSInteger, EFSNFXGTradeOrderStatus) {
    EFSNFXGTradeOrderStatusPrepareToOpen = 0, /**< 待发 */
    EFSNFXGTradeOrderStatusDismissed = 1, /**< 废单 */
    EFSNFXGTradeOrderStatusOpened = 2, /**< 已发 */
    EFSNFXGTradeOrderStatusClosed = 3 /**< 已撤 */
};

typedef NS_ENUM(NSInteger, EFSNFXGTradeConditionalOrderStatus) {
    EFSNFXGTradeConditionalOrderStatusNormal = 0, /**< 未触发 */
    EFSNFXGTradeConditionalOrderStatusOpened = 1, /**< 已出发 */
    EFSNFXGTradeConditionalOrderStatusClosed = 2 /**< 已撤单 */
};

typedef NS_ENUM(NSInteger, EFSNFXGTradeOrderType) {
    EFSNFXGTradeOrderTypeOrder = 0, /**< 委托单 */
    EFSNFXGTradeOrderTypeStopOrder = 1, /**< 止盈止损单 */
    EFSNFXGTradeOrderTypeConditionalOrder = 2 /**< 条件单 */
};

typedef NS_ENUM(NSInteger, EFSNFXGTradeConditionType) {
    EFSNFXGTradeConditionTypeBiggerThanTrigger = 0, /**< A.最新价>=触发价 */
    EFSNFXGTradeConditionTypeSmallerThanTrigger = 1 /**< B.最新价<=触发价 */
};

typedef NS_ENUM(NSUInteger, EFSNFXGTradeQueryStatus) {
    EFSNFXGTradeQueryStatusDefault,
    EFSNFXGTradeQueryStatusQuerying,
    EFSNFXGTradeQueryStatusQuerySuccess,
    EFSNFXGTradeQueryStatusQueryError,
};

static NSString *const NFXGTradeDomain = @"Trade_Domain"; /**< error domain */
static NSInteger const NFXGTradeSocketDisconnetErrorCode = -1; /**< sokect 断开 */
static NSInteger const NFXGTradeSocketTimeoutErrorCode = -2; /**< socket 超时 */

static NSString *const NFXGTradeSocketDisconnectNotification = @"EFS_Trade_Socket_Disconnet"; /**< socket断开通知 */

#endif
